<?php defined('SYSPATH') OR die('No direct access allowed.'); ?>

	<script type="text/javascript">
	 	dojo.require("dijit.Editor");
		dojo.require("dijit.form.ValidationTextBox");
		dojo.require("dojox.validate.regexp");
		dojo.require("dojo.parser");
	</script>
	
	<script type="text/javascript">
		$(document).ready(function() {
			$("input[name='btnCancle']").click(function() {
				var uri = ISS.lang.getBasePath()+'index.php/admin/club';
				window.location = uri;
			});
		}); 
	</script>
	
	<?php 	
	if (!empty($form['logo'])) {
		echo html::Stylesheet(
			array
			(
				'media/css/club_picture_block.css',
			),
			array
			(
				'screen',
			)
		);	
	}
	else {
		echo html::Stylesheet(
			array
			(
				'media/css/club_block.css',
			),
			array
			(
				'screen',
			)
		);	
	}
	?>
	
	<div id="clubContainer">
		<?php print form::open_multipart('admin/club/save');?>
	    
		    <div id="clubBlock">
		        <div id="clubBlockTop">
		          <h3><?php echo ($mode=='add') ? 'เพิ่มคลับเพลง' : 'แก้ไขคลับเพลง'; ?></h3>
		          	<?php 
		          		$array = array('mode' => $mode);
						print form::hidden($array);
						if ($mode=='edit') {
		          			$array = array('id' => $form['id']);
							print form::hidden($array);
						}
						?>
		          <p><?php echo (empty($status) ? 'กรุณาระบุข้อมูลให้ครบถ้วน' : html::specialchars($status)); ?></p>
		        </div>
		        <div id="clubBlockBody">
					<table>
						<tr>
							<td>ชื่อ::</td>
							<td>
								<input id="txtName" type="text" name="txtName"
									value="<?php echo html::specialchars($form['name']); ?>"
								    style="width: 100px;" 
								    dojoType="dijit.form.ValidationTextBox"
								    trim="true"
								    required="true"
								    invalidMessage="กรุณาระบุชื่อคลับเพลง" />
								<div id='errName' class='clubBlockError'>
									<?php echo (empty ($errors['txtName'])) ? '' : $errors['txtName']; ?>
								</div>
							</td>
						</tr>
						<tr>
							<td>คำอธิบาย::</td>
							<td>
								<textarea dojoType="dijit.Editor" id="txtDescription" name="txtDescription">
								<?php echo html::specialchars($form['description']); ?>
							  	</textarea>
								<div id='errDescription' class='clubBlockError'>
									<?php echo (empty ($errors['txtDescription'])) ? '' : $errors['txtDescription']; ?>
								</div>
							</td>
						</tr>
						<tr>
							<td>รูปภาพ::</td>
							<td>
								<?php
									if (!empty($form['logo'])) {
										echo '<img id=imgLogo  alt="'. html::specialchars($form['name']) .'" src="'. url::base() . html::specialchars($form['logo']) .'" />';
										echo '<br/>';
									} 
									$attributes = array('name' => 'txtLogo');
									echo form::upload($attributes, '');	
								?>
								<div id='errLogo' class='clubBlockError'>
									<?php echo (empty ($errors['txtLogo'])) ? '' : $errors['txtLogo']; ?>
								</div>
							</td>
						</tr>
					</table>
		        </div>
		     </div>
		     <div id="clubBlockBot">
		     	<?php 
		     		print form::submit('btnSave', 'บันทึก'); 
		     	?>
		     	<input type="button" id="btnCancle" name="btnCancle" value="ยกเลิก" />
		     </div>
		 <?php print form::close(); ?>
	 </div>
